//1.Object.values,和keys类似，输出的全是value
const obj = {
    foo: "value1",
    bar: "value2"
}
console.log(Object.values(obj))  //[ 'value1', 'value2' ]

//2.Object.entries:把对象里的内容转换成数组形式
console.log(Object.entries(obj)) //[ [ 'foo', 'value1' ], [ 'bar', 'value2' ] ]

//3.Object.getOwnPropertyDescripts:和get,set等一起使用(get,set在assign时，作为一个常量复制过去的，所以修改没有作用)
const p1 = {
    firstName: '张',
    lastName: '三',
    get fullName() {
        return this.firstName + '' + this.lastName
    }
}
console.log(p1.fullName)  //张三

const descriptor = Object.getOwnPropertyDescriptors(p1)
console.log(descriptor)
const p2 = Object.defineProperties({}, descriptor)
console.log(p2)
p2.firstName = "王"
console.log(p2.fullName)   //王三


//4.String.prototype.padStart / String.prototype.padEnd
/**
 * 参数：1.总共有多少位  2.不够的用什么字符补
 */
const books = {
    html: 16,
    css: 3,
    javascript: 128
}
for (let [name, count] of Object.entries(books)) {
    // console.log(name)
    // console.log(count)
    console.log(`${name.padEnd(16, '-')},${count.toString().padStart(3, '0')}`)
}

//5.在函数参数中添加尾逗号
function foo(m, n, k, j,) {
    console.log(m, n, k, j)
}

foo(1, 2, 3, 4,)